Skip to content

feat: DH-21476: Middleware plugin infrastructure for widget chaining#2660

Open
vbabich wants to merge 28 commits intodeephaven:mainfrom
vbabich:middleware-plugin-infra
Open

feat: DH-21476: Middleware plugin infrastructure for widget chaining#2660
vbabich wants to merge 28 commits intodeephaven:mainfrom
vbabich:middleware-plugin-infra

Conversation

@vbabich
Copy link
Copy Markdown
Collaborator

@vbabich vbabich commented Apr 13, 2026

Middleware Plugin Infrastructure for Widget Chaining

Summary

Adds middleware plugin support so plugins can wrap existing widgets without replacing them, cross-plugin dependency loading via manifest package/dependencies fields, and shared plugin-loading utilities in @deephaven/plugin.

What Changed

Middleware chaining — New WidgetMiddlewarePlugin type, identified by its own PluginType.MIDDLEWARE_PLUGIN discriminator. Middleware receives a Component prop and wraps the next layer. Multiple middleware compose in registration order. Applied in both WidgetLoaderPlugin (dashboard panels) and WidgetView (inline widgets) via createChainedComponent/createChainedPanelComponent. The chaining functions automatically filter middleware by supportedTypes at render time, so middleware only activates for matching widget types.

Cross-plugin dependencies — Manifest entries can declare package (makes the plugin's exports available to other plugins) and dependencies (topological sort so deps load first). Plugins load sequentially so each plugin's exports are available to subsequent plugins via standard import statements.

Shared loading utilitiesgetPluginModuleValue, registerPlugin, processLoadedModule, sortPluginsByDependency, and manifest types moved from @deephaven/app-utils into @deephaven/plugin. Both web-client-ui and gplus consume these instead of duplicating the logic. ~80 lines removed from app-utils.

Behavior change — duplicate plugin names. When two plugins in the manifest are loaded under the same name, the shared registerPlugin now skips the duplicate and keeps the first registration (with a warning). Previously the duplicate replaced the existing entry. This applies to plugin-name collisions in the plugin map; widget-type resolution in WidgetLoaderPlugin is unaffected (last base plugin still wins for a given widget type).

Key Files

File Change
packages/plugin/src/PluginTypes.ts Middleware types, type guard
packages/plugin/src/PluginUtils.tsx Chaining functions, loader utils, manifest types
packages/plugin/src/sortPluginsByDependency.ts Topological sort for plugin dependencies
packages/plugin/src/WidgetView.tsx Middleware-aware inline rendering
packages/dashboard-core-plugins/src/WidgetLoaderPlugin.tsx Middleware-aware panel loading
packages/app-utils/src/plugins/PluginUtils.tsx Simplified to use shared utils
packages/plugin/docs/middleware-architecture.md Architecture reference

BREAKING CHANGE: PluginManifestPluginInfo, PluginManifest, and
getPluginModuleValue have been moved from @deephaven/app-utils to
@deephaven/plugin. Update imports from @deephaven/app-utils to
@deephaven/plugin.

vbabich added 4 commits April 13, 2026 07:15
Add support for middleware plugins that can wrap and enhance widget plugins.
Multiple middleware plugins can target the same widget type and are chained
in registration order (first registered = outermost wrapper).

- Add WidgetMiddlewarePlugin interface with isMiddleware marker
- Add WidgetMiddlewareComponentProps and WidgetMiddlewarePanelProps
- Add isWidgetMiddlewarePlugin() type guard
- Update WidgetLoaderPlugin to collect and chain middleware plugins
- Update WidgetView to support middleware chaining
- Add unit tests for middleware chaining behavior
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 13, 2026

Codecov Report

❌ Patch coverage is 88.01843% with 26 lines in your changes missing coverage. Please review.
✅ Project coverage is 50.05%. Comparing base (3ed691d) to head (5b3e45f).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
packages/plugin/src/WidgetView.tsx 0.00% 23 Missing ⚠️
.../dashboard-core-plugins/src/WidgetLoaderPlugin.tsx 96.29% 2 Missing ⚠️
packages/plugin/src/PluginUtils.tsx 99.21% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2660      +/-   ##
==========================================
+ Coverage   49.54%   50.05%   +0.50%     
==========================================
  Files         774      774              
  Lines       43898    44074     +176     
  Branches    11308    11171     -137     
==========================================
+ Hits        21749    22060     +311     
+ Misses      22103    21996     -107     
+ Partials       46       18      -28     
Flag Coverage Δ
unit 50.05% <88.01%> (+0.50%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@vbabich vbabich marked this pull request as ready for review April 13, 2026 13:53
@mofojed mofojed self-requested a review April 14, 2026 19:41
Copy link
Copy Markdown
Member

@mofojed mofojed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall, just a couple comments/questions

Comment thread packages/plugin/src/PluginUtils.tsx Outdated
Comment thread packages/plugin/src/PluginTypes.ts Outdated
@vbabich
Copy link
Copy Markdown
Collaborator Author

vbabich commented Apr 27, 2026

Our e2e tests fail in main on deephaven:edge.
deephaven:latest works fine; the issue must be introduced on the deephaven-core side.

@vbabich vbabich requested a review from mofojed April 30, 2026 18:36
@@ -0,0 +1,110 @@
import Log from '@deephaven/log';
import { type PluginManifestPluginInfo } from './PluginUtils';
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason sortPluginsByDependency is in it's own file? Circular reference here between PluginUtils/this, though it's just types... but I'd probably just move this to PluginUtils, or have a utils folder for other utils, or move the type into PluginTypes or something.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I originally had this function in the utils file, then decided to move it out to a separate file, but didn't check for circular dependencies. Moved it back. Ok if I keep the tests in a separate file?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants